# @Author ZhangGJ
# @Date 2021/12/01 09:40

import cv2.cv2 as cv2


# 滤波操作
def blur():
    img = cv2.imread('../images/amygdalus triloba.png')
    dst1 = cv2.blur(img, (3, 3))
    dst2 = cv2.blur(img, (5, 5))
    dst3 = cv2.blur(img, (9, 9))
    cv2.imshow('img', img)
    cv2.imshow('3*3', dst1)
    cv2.imshow('5*5', dst2)
    cv2.imshow('9*9', dst3)
    cv2.waitKey()
    cv2.destroyAllWindows()


# 中值滤波
def median_blur():
    img = cv2.imread('../images/amygdalus triloba.png')
    dst1 = cv2.medianBlur(img, 3)
    dst2 = cv2.medianBlur(img, 5)
    dst3 = cv2.medianBlur(img, 9)
    cv2.imshow('img', img)
    cv2.imshow('3', dst1)
    cv2.imshow('5', dst2)
    cv2.imshow('9', dst3)
    cv2.waitKey()
    cv2.destroyAllWindows()


# 高斯滤波
def gaussian_blur():
    img = cv2.imread('../images/amygdalus triloba.png')
    dst1 = cv2.GaussianBlur(img, (5, 5), 0, 0)
    dst2 = cv2.GaussianBlur(img, (9, 9), 0, 0)
    dst3 = cv2.GaussianBlur(img, (15, 15), 0, 0)
    cv2.imshow('img', img)
    cv2.imshow('5', dst1)
    cv2.imshow('9', dst2)
    cv2.imshow('15', dst3)
    cv2.waitKey()
    cv2.destroyAllWindows()


# 双边滤波
def bilateral_filter():
    img = cv2.imread('../images/amygdalus triloba.png')
    dst1 = cv2.GaussianBlur(img, (15, 15), 0, 0)
    dst2 = cv2.bilateralFilter(img, 15, 120, 100)
    cv2.imshow('img', img)
    cv2.imshow('gauss', dst1)
    cv2.imshow('bilateral', dst2)
    cv2.waitKey()
    cv2.destroyAllWindows()


if __name__ == '__main__':
    bilateral_filter()
